#include <stdio.h>


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CeleMenu
class Menu
{
protected:
	HMENU m_hMenu;

public:
	Menu(HMENU hMenu = NULL)
	{
		m_hMenu = hMenu;
	}

	HMENU operator =(HMENU hMenu)
	{
		return m_hMenu = hMenu;
	}

	operator HMENU()
	{
		return m_hMenu;
	}

	BOOL Enable(UINT uCmd, BOOL bEnable = TRUE)
	{
		return EnableMenuItem(m_hMenu, uCmd, bEnable ? MF_ENABLED : MF_GRAYED);
	}

	BOOL Check(UINT uCmd, BOOL bChecked = TRUE)
	{
		return CheckMenuItem(m_hMenu, uCmd, bChecked ? MF_CHECKED : MF_UNCHECKED);
	}

	BOOL CheckRadio(UINT uFirst, UINT uLast, UINT uCmd)
	{
		return CheckMenuRadioItem(m_hMenu, uFirst, uLast, uCmd, MF_BYCOMMAND);
	}

	BOOL IsChecked(UINT uCmd)
	{
		MENUITEMINFO mi;
		mi.cbSize = sizeof(MENUITEMINFO);
		mi.fMask = MIIM_STATE;
		return GetMenuItemInfo(m_hMenu, uCmd, FALSE, &mi) && (mi.fState & MFS_CHECKED);
	}

	BOOL IsExist(UINT uCmd)
	{
		MENUITEMINFO mi;
		mi.cbSize = sizeof(MENUITEMINFO);
		mi.fMask = 0;
		return GetMenuItemInfo(m_hMenu, uCmd, FALSE, &mi);
	}

	UINT GetItemCount()
	{
		UINT nCount = 0;
		MENUITEMINFO mi;
		mi.cbSize = sizeof(MENUITEMINFO);
		mi.fMask = 0;
		while (GetMenuItemInfo(m_hMenu, nCount, TRUE, &mi))
		{
			nCount++;
		}
		return nCount;
	}

	BOOL GetText(UINT uCmd, PTSTR ptzStr)
	{
		MENUITEMINFO mi;
		mi.cbSize = sizeof(MENUITEMINFO);
		mi.fMask = MIIM_TYPE;
		mi.cch = MAX_NAME;
		mi.dwTypeData = ptzStr;
		ptzStr[0] = 0;
		return GetMenuItemInfo(m_hMenu, uCmd, FALSE, &mi);
	}

	BOOL SetText(UINT uCmd, PCTSTR ptzStr)
	{
		MENUITEMINFO mi;
		mi.cbSize = sizeof(MENUITEMINFO);
		mi.fMask = MIIM_TYPE;
		mi.fType = MFT_STRING;
		mi.dwTypeData = (PTSTR) ptzStr;
		return SetMenuItemInfo(m_hMenu, uCmd, FALSE, &mi);
	}

	BOOL Popup(HWND hParent, INT iLeft, INT iTop, UINT uFlags = 0)
	{
		return TrackPopupMenuEx(m_hMenu, uFlags, iLeft, iTop, hParent, NULL);
	}
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main(int argc, char *argv[])
{
	printf("Hello, world\n");
	
	return 0;
}
